package com.mx.zb.mng.utils.context;

import java.io.IOException;
import java.util.Map;

import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import com.alibaba.fastjson.JSONObject;

/**
 * 
 * @ClassName: AccessLogConfig
 * @Description: 读取各种的配置
 * @author 张博
 * @date 2017年10月23日 下午7:44:12 
 *
 */
public class JsonConfig {
	
	private static final JSONObject accessLogConfig;
	
	static {
		Resource res = new ClassPathResource("accessLogConfig.json");
		String text;
		try {
			text = IOUtils.toString(res.getInputStream(),"utf8");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			throw new RuntimeException(e);
		}
		accessLogConfig = JSONObject.parseObject(text);
	}
	
	public static String get(String path, String method) {
		Map v1=(Map)accessLogConfig.get(path);
		if(v1!=null) {
			return (String)v1.get(method);
		}
		return null;
	}
	
	public static JSONObject getJson() {
		
		return accessLogConfig;
	}
	
	
	public static void main(String[] args) {
		System.out.println(getJson());
	}

}
